<template>
  <div px-32rpx pt-32rpx>
    <div bg-white flex flex-a-c flex-j-sb flex-col py-32rpx rounded-8rpx>
      <div mt-40rpx>预存款金额</div>
      <div mb-40rpx mt-20rpx color-black text-56rpx>
        {{ unitPrice(walletNum, '￥') }}
      </div>
      <div flex flex-a-c gap-30rpx mb-40rpx>
        <div @click="$navigateTo('/pages/mine/wallet/withdraw')" w-204rpx h-90rpx rounded text-main-color bg-main-color-10
          text-center line-height-90rpx>
          提现
        </div>
        <div @click="$navigateTo('/pages/mine/wallet/recharge')" w-204rpx rounded h-90rpx bg-main-color text-center
          line-height-90rpx color-white>
          充值
        </div>
      </div>
    </div>
    <nut-cell @click="$navigateTo('/pages/mine/wallet/log')" title="预存款明细" is-link></nut-cell>
    <nut-cell @click="$navigateTo('/pages/mine/wallet/withdrawlog')" title="提现记录" is-link></nut-cell>
  </div>
</template>

<script setup lang="ts">
import { unitPrice } from '@/utils/filters';
import { getUserWallet } from "@/api/member";
import { onShow } from '@dcloudio/uni-app';
import { navigateToLogin } from '@/utils/filters';
import { isLogin } from '@/utils/filters';

const walletNum = ref<number>(0);

async function navigate() {
  if (isLogin("auth")) {
    let result = await getUserWallet(); //预存款
    walletNum.value = result.data.result.memberWallet;
  }
  else {
    navigateToLogin();
  }
}
onShow(async () => {
  await navigate();
});
</script>

<style scoped>
</style>
